{template 'common/header'}
<link href="{MODULE_URL}template/web/css/classlist.css" rel="stylesheet" type="text/css">
    <div class="list_th">
        <div class="td" style=" width:20%;">
            <div class="left_padding">广告标题</div>
        </div>
        <div class="td text-center" style=" width:20%;">创建日期</div>
        <div class="td text-center" style=" width:20%;">到期时间</div>
        <div class="td text-center" style=" width:10%;">排序</div>
        <div class="td text-center" style=" width:30%;">
            <div class="list_right text-center">操作</div>
        </div>
        <div class="clear"></div>
    </div>
    {if $ad}
    {loop $ad $k $o}
    <div class="list_tr link_bk">
            <div class="td text-center" style=" width:20%;">
                <div class="category_input left_padding">
                    <input name="save_id[]" type="hidden" value="{$o['id']}"/>
                    <input name="title"  type="text" class="input_text_default small " maxlength="20" value="{$o['title']}" style=" width: 120px;"/>
                    <span style="color:#999999; margin-left: 5px; font-size: 13px;">[id:{$o['id']}]</span>
                </div>
                <div class="clear"></div>
            </div>
            <div class="td text-center" style=" width:20%;" >
                {php echo date('Y-m-d',$o['addtime'])}
            </div>
            <div class="td text-center" style=" width:20%;" >
                {php echo date('Y-m-d',$o['term'])}
            </div>            
            <div class="td text-center" style=" width:10%;" >
                {$o['orderid']}
            </div>              
            <div class="td edit text-center" style=" width:30%;">
                <div class="list_right btn">
                    <a href="{php echo $this->createWebUrl('adedit',array('oid'=>$o['id']));}">编辑</a>
                    <a class="green hide_{$o['ishide']} ishide" did="{$o['id']}" sid="{$o['ishide']}">显隐</a>
                     <a class="gray delete" did="{$o['id']}">删除</a>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    {/loop}
    {else}  
    {/if}
    <div class="list_tr">
        <div class="td" style="width: 60%;">
            <a class="J_add category_list_add" level="1" pid="0" href="{php echo $this->createWebUrl('adadd');}">添加广告</a>
            <div class="clear"></div>
        </div>
    </div>    
<style type="text/css">.right-content{padding: 0;}.hot_1{background-color: red;}</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script>      
<script type="text/javascript">
    
 $(document).on('click','.ishide',function(){
            var ssid = $(this).attr('sid');
            var obj  = $(this);
           $.ajax({
                     url:"{php echo $this->createWebUrl('adishide');}&version_id="+"{$_GPC['version_id']}",
                     data:{oid:$(this).attr('did'),sid:$(this).attr('sid')},
                     dataType:"json",
                     type:"post",
                    success:function(res){
                       if(res.status== 1){  
                           if(ssid=='1'){   
                            obj.addClass('hide_0');
                            obj.attr('sid','0'); 
                           }else{                           
                            obj.removeClass('hide_0');
                            obj.attr('sid','1');
                           }
                            mqToast({type:1,context: res.msg}); 
                            return false;
                       }else{
                           mqToast({type:1,context: res.msg}); 
                           return false;
                       }
                    }
                  });
    });
 //删除广告
    $(document).on('click','.delete', function () {
              if(!confirm("确定要删除该广告吗！")){                
                   window.event.returnValue=false;
               }else{
                   $.ajax({
                       url:"{php echo $this->createWebUrl('addel');}&version_id="+"{$_GPC['version_id']}",
                       data:{did:$(this).attr('did')},
                       dataType:"json",
                       type:"post",
                      success:function(res){
                         if(res.status== 1){
                             mqToast({type:1,context: res.msg}); 
                            setTimeout(function(){
                                window.location.reload(); 
                              },2000); 
                             return false;
                         }else{
                             mqToast({type:1,context: res.msg}); 
                             return false;
                         }
                      }
                    })                    
               }        
    });
</script>
{template 'common/footer'}    